<template>
  <div>
    <h1 align="center">管理员页面</h1>
    <table class="table table-bordered">
      <tr>
        <td align="center">用户名</td>
        <td>
          <input type="text" v-model="state.username"  />
        </td>
      </tr>
      <tr>
        <td align="center">密码</td>
        <td>
          <input type="password"  v-model="state.password" />
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center">
          <input
            type="button"
            value="登录"
            class=" btn btn-primary"
            @click="Denglu"
          />
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { reactive, toRefs, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
let data: any = reactive({
  state: {
    username: '',
    password: ''
  }
});
let  {state} = toRefs(data);
const Denglu = () => {
  let obj = {
    user: state.value.username,
    userpass: state.value.password
  };
  axios({
    url: '/api/Admin/DengLU',
    method: 'get',
    params: obj
  })
    .then((res) => {
      console.log(res);
      if (res.data.data == null) {
        alert('用户名不存在,请联系管理员');
        return;
      } else {
        alert('登录成功');
        router.push({ path: '/about' });
      }
    })
    .catch((err) => {
      console.log(err);
    });
};
</script>

<style scoped></style>
